<template>
  <div class="LineShapeGeometry-container">
    <de-collapse-layout
      label="路径"
      icon="#iconjichubianhuan"
      arrowPosition="left"
    >
      <template #container>
        <el-button
          size="mini"
          type="primary"
          icon="el-icon-circle-plus-outline"
          class="path-add"
          @click="addPoint"
        >
          添加路径
        </el-button>

        <div
          class="path-point-item"
          v-for="(item, index) in config.path"
          :key="index"
        >
          <de-controller-vector2
            :keyframe="false"
            :label="'锚点' + index"
            :step="1"
            :displayAccuracy="2"
            :value="item"
          ></de-controller-vector2>

          <i
            class="el-icon-delete"
            v-show="config.path.length > 1"
            @click="deletePoint(index)"
          ></i>
        </div>
      </template>
    </de-collapse-layout>
    <de-controller-number
      :keyframe="false"
      label="分段"
      :step="1"
      :dragMultply="2"
      :min="3"
      v-model="config.curveSegments"
    ></de-controller-number>
  </div>
</template>

<script>
export default {
  props: {
    config: {
      type: Object,
      required: true,
    },
  },

  methods: {
    addPoint() {
      this.config.path.push({
        x: 0,
        y: 0,
        z: 0,
      });
    },

    deletePoint(index) {
      this.config.path.splice(index, 1);
    },
  },
};
</script>

<style lang="less" scoped>
.path-add {
  margin-bottom: @box-margin / 2;
}

.path-point-item {
  .flexLayout(row, space-between, center);
  > i {
    padding: @box-padding / 2;
    color: @error-color;
    cursor: pointer;
  }
}

.path-add,
.path-point-item {
  width: 100%;
}
</style>
